/**
 * 
 */
package com.scpii.universal.hibernate.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.scpii.universal.constant.GenericConstants;
import com.scpii.universal.hibernate.dao.DataSortDao;
import com.scpii.universal.hibernate.entity.DataSortTab;


/**
 * genericWeb
 * @author acer
 * 2012-7-5下午04:35:11
 */
@Repository
public class DataSortDaoImpl extends BaseDaoImpl<DataSortTab, Integer> implements DataSortDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<DataSortTab> getSelectedSortColumns(int intViewId,
			int isShowInClient) {
		if (intViewId <= 0)
			return null;
		String hql = "from DataSortTab d where d.intDeleteSign=?"
				+ " and d.intIsShowInClient=? and d.intViewId=?";
		return getHibernateTemplate().getSessionFactory().getCurrentSession()
				.createQuery(hql)
				.setParameter(0, GenericConstants.DELETE_SIGN_EXIST)
				.setParameter(1, isShowInClient).setParameter(2, intViewId)
				.list();
	}

	@Override
	public void delSelectedSortCols(int intViewId) {
		String hql = "delete from DataSortTab d where d.intViewId=?";
		getHibernateTemplate().getSessionFactory().getCurrentSession()
				.createQuery(hql).setParameter(0, intViewId).executeUpdate();
	}

}
